package com.example.java.Controller;

import com.example.java.Entity.User;
import com.example.java.Service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    //    查询所有
    @GetMapping("/all")
    public List<User> alluser(){
        return userService.alluser();
    }


    //    增加或修改
    @PostMapping("/AddandEdit")
    public Integer addandedit(@RequestBody User user) {
        return userService.addandedit(user);
    }

    //    删除
    @DeleteMapping("/delete/{id}")
    public Integer delete(@PathVariable Integer id){
        return userService.deleteById(id);
    }

    //    模糊查询
    @GetMapping("/getLike/{name}")
    public List<User> getLike(@PathVariable String name) {
        return userService.getLike(name);
    }
}
